Google News
logo
MongoDB - Quiz(MCQ)
Which of the following query selects documents in the records collection that match the condition { "user_id": { $lt: 42 } }?
A)
db.records.find( { “user_id”: { $lt: 42 } }, { “history”: 0 } )
B)
db.records.select( { “user_id”: { $lt: 42 } }, { “history”: 0 } )
C)
db.records.findOne( { “user_id”: { $lt: 42 } }, { “history”: 1 } )
D)
db.records.findOne( { “user_id”: { $lt: 42 } }, { “history”: 0 } )

Correct Answer :   db.records.find( { “user_id”: { $lt: 42 } }, { “history”: 0 } )


Explanation : Query uses the projection { “history”: 0 } to exclude the history field from the documents in the result set.

Advertisement